/*
    This file is part of Lua Invoke.
    Copyright 2005-2007 Rafael de Oliveira Jannone <rafael@jannone.org>

    Lua Invoke is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/* win32 specific */

#include "port_win32.h"

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
	/* FIXME: dev-cpp generates this switch, it might be useful somehow...? */
	/*
	switch (reason)
	{
		case DLL_PROCESS_ATTACH:
		break;

		case DLL_PROCESS_DETACH:
		break;

		case DLL_THREAD_ATTACH:
		break;

		case DLL_THREAD_DETACH:
		break;
	}
	*/
	/* Returns TRUE on success, FALSE on failure */
	return TRUE;
}


/* some dl wrappers for windows */

const char*
dlerror()
{
	return NULL;
}

void*
dlopen(const char* dll, int t)
{
	HINSTANCE ret = LoadLibrary(dll);
	return ret;
}

void
dlclose(void* handle)
{
	FreeLibrary((HINSTANCE)handle);
}

void*
dlsym(void* handle, const char* name)
{
	return (void*)GetProcAddress((HMODULE)handle, name);
}
